/*!
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 *
 *    Author: flareguner
 *    E-Mail: flareguner@gmail.com
 *    Years: 2010-2011
 */


#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>


class QAction;
class QToolBar;
class QMenuBar;
class QMenu;
class QSettings;
class QTranslator;
class QCliboard;
class QStatusBar;

class QxtGlobalShortcut;



class TranslationTabWidget;
class TrayIcon;
class Settings;
class Exceptions;
class History;
class DictionaryWidget;
class Popup;
class Pronounce;
class Translate;
//class

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
public slots:
    // Primary slots for actions
        void open();
        void save();
        void saveAs();
        void print();
        void translate();
        void exit();

//        void clear();
//        void copy();
//        void undo();
//        void redo();
//        void swap();

        void pronounce();
//        void history();
//        void exceptions();

        void about();
        void aboutQt();


        void setLocked(bool);
        void lock();
        void unlock();
public:
        //Instances for plugins and dbus
        TranslationTabWidget *translationTabIntance();
        TrayIcon *trayIconInstance();
        Settings *settingsInstance();
        Exceptions *exceptionsInstance();
        History *historyInstance();
        DictionaryWidget *dictionaryInstance();
        Popup *popupInstance();
        Pronounce *pronounceInstance();
        Translate *translateInstance();

        QStatusBar *statusbarInstance();
        QToolBar *mainToolBar();
        QMenu *toolsMenuInstance();
protected:
    void changeEvent(QEvent *);
private:
    void createActions();
    void createToolbar();
    void createMenu();
    void createTools();
    void createWidgets();
    void createUi();
    void createConnections();

    void initApplication();

    bool isPopupable();
private slots:
    void updateSettings();
    void selectionChangeHandler();
    void directionChangeHandler();
    void textChangeHandler();


    void dictQuery(const QString &text);
private:
    QAction

    // File
    *openAction,
    *saveAction,
    *saveAsAction,
    *printAction,
    *translateAction,
    *exitAction,

    // Edit
    *clearAction,
    *copyAction,
    *undoAction,
    *redoAction,
    *swapAction,

    // Tools
    *settingsAction,
    *docksAction,
    *pronounceAction,
    *historyAction,
    *exceptionsAction,
    *autoDetectAction,
    *autoTranslateAction,
    *scanSelectionAction,

    // Dockers actions
    *dictionaryAction,

    // Help
    *aboutAction,
    *aboutQtAction;


    QToolBar
    *mainToolbar;

    QMenuBar
    *mainMenubar;

    QMenu
    *fileMenu,
    *editMenu,
    *toolsMenu,
    *dockersMenu,
    *helpMenu;


    TranslationTabWidget
    *m_tab_widget;

    TrayIcon
    *m_tray_icon;

    Settings
    *m_settings;

    Exceptions
    *m_exceptions;

    History
    *m_history;

    //Dockers
    DictionaryWidget
    *m_dict_widget;

    Popup
    *m_popup;

    Pronounce
    *m_pronounce;

    Translate
    *m_translate;

    QSettings
    *m_window_settings;

    QTranslator
    *m_last_translator,
    *m_translator;

    QStatusBar
    *m_status_bar;


    QxtGlobalShortcut
    *m_translation_shortcut;

    QClipboard *m_cliboard;
};

#endif // MAINWINDOW_H
